/**
 * 删除上传的图片
 */
function deleteCover(value) {
	$("#" + value).remove();
}

/**
 * 主页
 */
define(['jquery',
	'base',
	'baseUtils',
    'msgTool',
	'css!global/plugins/fileInput/fileinput.min.css',
	'plugins/fileInput/fileinput.min'
	], function ($, base, baseUtils,msgTool, _) {
	//默认加载基础库
	base();
	
    
	//执行
	return {
		info: function () {		

			/**
			 * 提交申请材料
			 */
		    $("#saveSuggestionForm").validate({
		    	ignore: [],
		        rules: {
		        	content:{
		        		 required: true
		        	}
		        },
		        messages: {
		        	content:{
		        		 required: errorIcon + "投诉/建议内容不能为空"
		        	}
		        }
		    });
			$("#doSubmit").on('click', function () {
		    var valid = $("#saveSuggestionForm").valid();
				if(valid){
					 $.ajax({
					    	type:"POST",
					    	url:"/suggestion/save",
					    	data:$("#saveSuggestionForm").serialize(),
					    	dataType:"json",
					    	   beforeSend: function () {
		                            //触发ajax请求开始时执行
		                            $("#doSubmit").text('提交中...');
		                            $("#doSubmit").attr('disabled', 'disabled');
		                        },
					    	success:function(data){
					    		 if (data.success) {
		                            	msgTool.success("提交成功");
		                            	setTimeout(function () {
		                            		window.location.href = "/user/suggestion";
		                            		}, 3000);
		                            } else {
		                            	msgTool.error(data.msg);
		                            	$("#doSubmit").removeAttr('disabled');
		                            }
					        }
					    });
				}

			});

		},

		save: function () {
	
		      
		}
	}

});
